<template>
	<view class="page" :style="{minHeight:$height()}">
		<view class="header">
			<view class="headerTitle">
				余额
			</view>
			<view class="eDu">
				<text class="eDuIocn">￥</text> <text class="eDuNum">{{userinfo.money}}</text>
			</view>
			<view class="leiBox">
				<view class="leiBoxItem">提现中：</view>
				<view class="leiBoxItem" style="margin: 0;">￥</view>
				<view class="leiBoxItem">{{count.cashOutIng}}</view>
				<view class="leiBoxItem">|</view>
				<view class="leiBoxItem">累计提现：</view>
				<view class="leiBoxItem" style="margin: 0;">￥</view>
				<view class="leiBoxItem">{{count.cashOutSuccess}}</view>
			</view>
			<view class="submit" @click="$next(`/pages/withDrawal/withdrawal`)">
				提现
			</view>
			<view class="embodyManagement" @click="$next(`/pages/withDrawal/bankCardList`)">
				收款账户管理
			</view>
		</view>

		<view class="footer">
			<view class="footerHeader">
				<view class="footerHeaderLift">
					提现明细
				</view>
				<view class="footerHeaderRight" @click="selectStaus">
					<text class="footerTxt">{{statusText=="" ? '全部' : statusText}}</text>
					<u-icon name="arrow-down" style="color: #3975EA;"></u-icon>
				</view>
			</view>
			<!-- <u-select v-model="show" :list="statusList" @confirm="confirm"></u-select> -->
			<u-picker mode="selector" v-model="show" :default-selector="[0]" :range="statusList" range-key="label" @confirm="confirm"></u-picker>

			<view class="footerItem" v-for="(item,index) in list" :key="index"  @click="$next(`${pagesArr[item.status]}?id=${item.id}`)">
				<view class="footerItemLeft">
					<view class="li">
						提现单号：{{item.orderSn}}
					</view>
					<view class="li">
						提现金额：￥ {{item.money}}
					</view>
					<view class="li date">
						{{item.createDate}}
					</view>
				</view>
				<view class="footerItemRight">
					<view :class="{statusType0:item.status == 0,statusType1:item.status == 1,statusType2:item.status == 2}">
						{{statusList[item.status+1].label}}
					</view>
				</view>
			</view>
			<!-- 加载更多 -->
			<u-loadmore v-if="list.length !== 0" :status="status" :load-text="loadText" />
			<image v-else src="@/static/image/empty.png" mode="widthFix" class="is-empty"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				status: '',
				userinfo: {},
				statusText: '',
				count: {
					statusCount0: 0,
					statusCount1: 0,
					statusCount2: 0,
				},
				pagesArr:['/pages/withDrawal/detailFinanceIng','/pages/withDrawal/detailFinanceSuccess','/pages/withDrawal/detailFinanceError'],
				// 页面数据初始化状态
				loadText: {
					loadmore: '轻轻上拉，加载更多',
					loading: '努力加载中',
					nomore: '我也是有底线的'
				},
				more: false,
				page: 1, //页码
				limit: 10, //条数
				list: [],
				statusList: [{
						value: '0',
						label: '全部'
					},
					{
						value: '1',
						label: '提现中'
					},
					{
						value: '2',
						label: '提现成功'
					}, {
						value: '3',
						label: '提现失败'
					}
				]

			}

		},
		mounted() {
			uni.$on('reload', (res) => {
				this.page = 1
				this.getFinanceCashRes()
			})
		},
		onShow() {
			this.getUser()
			this.getFinanceCount()
		},
		onLoad() {
			this.getFinanceCashRes()
		},
		//下拉刷新
		onPullDownRefresh() {
			this.page = 1
			this.getFinanceCashRes()
		},
		//上拉加载
		onReachBottom() {
			if (this.page == 1) {
				return
			}
			if (this.more) {

				this.getFinanceCashRes()
			}
		},
		methods: {
			getFinanceCount() {
				this.$axios.request(this.$api.countFinanceCash, "GET").then((val) => {
					this.count = val.data
				})
			},
			getFinanceCashRes() {
				var params = {
					page: 1,
					limit: 10,
					type: '1,2',
					orderField: 'id',
					order: 'desc'
				}

				if (this.status > 0) {
					params.status = this.status - 1
				}
				this.$axios.request(this.$api.getFinanceCashRes, "GET", params).then((val) => {
					uni.stopPullDownRefresh();
					this.list = this.page == 1 ? val.data.list : this.list.concat(val.data.list)
					if (Math.ceil(val.data.total / this.limit) > this.page) {
						this.more = true
						this.page++
					} else {
						this.more = false
					}
				})
			},
			getUser() {
				this.$axios.request(this.$api.getUser, "GET").then((val) => {
					this.userinfo = val.data
				})
			},
			selectStaus() {
				this.show = true
			},
			confirm(e) {
				if (e[0] == 0) {
					this.status = e[0]
					this.statusText = '全部'
				}
				if (e[0] == 1) {
					this.status = e[0]
					this.statusText = '提现中'
				}
				if (e[0] == 2) {
					this.status = e[0]
					this.statusText = '提现成功'
				}
				if (e[0] == 3) {
					this.status = e[0]
					this.statusText = '提现失败'
				}
				this.page = 1
				this.getFinanceCashRes()

			},

			goDetail(obj){
				
			}
		}
	}
</script>

<style>
	.page {
		width: 100%;
		background-color: #F3F4F8;
		overflow-y: hidden;
	}

	.header {
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		width: 750rpx;
		height: 388rpx;
		background-color: #3975EA;
	}

	.headerTitle {
		font-size: 20rpx;
		font-family: "PingFang SC";
		font-weight: 300;
		color: #FFFFFF;
	}

	.eDu {

		margin: 12rpx 0 18rpx;
	}

	.leiBox {
		display: flex;
		justify-content: center;
		font-size: 20rpx;
		font-family: "PingFang SC";
		font-weight: 300;
		color: #FFFFFF;
	}

	.leiBoxItem {
		margin: 0 10rpx;
	}

	.submit {
		width: 120rpx;
		height: 64rpx;
		border: 1rpx solid #3975EA;
		border-radius: 4rpx;
		font-size: 28rpx;
		font-family: "PingFang SC";
		font-weight: 400;
		line-height: 64rpx;
		text-align: center;
		color: #3975EA;
		background-color: #fff;
		margin: 56rpx 0 20rpx;
	}

	.embodyManagement {
		font-size: 28rpx;
		font-family: "PingFang SC";
		font-weight: 400;
		color: #FFFFFF
	}

	.eDuNum {
		font-size: 36rpx;
		font-family: "PingFang SC";
		font-weight: 600;
		color: #FFFFFF;
	}

	.eDuIocn {
		font-size: 13px !important;
		margin-right: 20rpx;
		font-family: "PingFang SC";
		font-weight: 600;
		color: #FFFFFF;
	}

	.footer {
		width: 100%;
		/* height: 836rpx; */
		height: 100%;
		background-color: #fff;
		margin-top: 12rpx;
		overflow-y: auto;
		/* background-color: #3975EA; */
	}

	.footerHeader {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 702rpx;
		padding: 0 8rpx;
		margin: 0 auto 0;
		height: 96rpx;
		border-bottom: 1rpx solid #F1F1F1;
	}

	.footerHeaderLift {
		font-size: 28rpx;
		font-family: 'PingFang SC';
		font-weight: 600;
		color: #333333;
	}

	.footerHeaderRight {
		display: flex;
		justify-content: flex-end;
		align-items: center;
		width: 50%;
		height: 100%;
	}

	.footerTxt {
		font-size: 24rpx;
		font-family: 'PingFang SC';
		font-weight: 600;
		color: #3975EA;
		margin-right: 12rpx;
	}

	.footerItem {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 702rpx;
		height: 142rpx;
		border-bottom: 1rpx solid #F1F1F1;
		border-radius: 4rpx;
		margin: 0 auto 0;
	}

	.footerItemLeft,
	.footerItemRight {
		display: flex;
		justify-content: center;
		align-items: flex-start;
		flex-direction: column;
		height: 100%;
	}

	.footerItemRight {
		align-items: center;
	}

	.li {
		font-size: 24rpx;
		font-family: 'PingFang SC';
		font-weight: 300;
		color: #333333;
		margin: 3rpx;
	}

	.date {
		font-size: 20rpx;
		font-family: .PingFang SC;
		font-weight: 500;
		color: #999999;
		margin-top: 16rpx;
	}

	.statusType0 {
		font-size: 24rpx;
		font-family: "PingFang SC";
		font-weight: 400;
		color: #FFA12A;
	}

	.statusType1 {
		font-size: 24Rpx;
		font-family: "PingFang SC";
		font-weight: 400;
		line-height: 46px;
		color: #3975EA;
	}

	.statusType2 {
		font-size: 24rpx;
		font-family: "PingFang SC";
		font-weight: 400;
		color: #FF2D55;

	}

	.lookYuanYin {
		font-size: 20rpx;
		font-family: "PingFang SC";
		font-weight: 300;
		color: #666666;
		margin-top: 8rpx;
	}

	.daoZhang {
		font-size: 24rpx;
		font-family: 'PingFang SC';
		font-weight: 400;
		color: #6FC954;
	}
</style>
